<?php

namespace App\Models\Shop;

use App\Models\User\WxUser;
use App\Wen\Utils\UserUtils;
use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class WxShop extends Model
{
	use HasDateTimeFormatter;
    use SoftDeletes;

    protected $table = 'wx_shop';

    public function user()
    {
        return $this->hasOne(WxUser::class, 'id', 'user_id');
    }

    public function getShopNameAttribute($v)
    {
        if($v){
            return $v;
        }
        if($this->shop_type == 1){
            return UserUtils::get_cached_user_name($this->user_id).'的店';
        }
    }

}
